package com.restaurant.application.indexes.couponmanagelist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;
import java.util.stream.Collectors;

public class DeleteData implements PickableBean {

    public static final String FN_IDLIST = "idList";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_IDLIST);

    private List<CouponManageIdData> idList;

    public DeleteData(List<CouponManageIdData> idList) {
        setIdList(idList);
    }

    public DeleteData() {
    }

    public DeleteData duplicate() {
        DeleteData result = new DeleteData();
        result.idList = this.idList == null ? null : this.idList.stream().map(e1->e1 == null ? null : e1.duplicate()).collect(Collectors.toList());
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public List<CouponManageIdData> getIdList() {
        if( idList == null) {
            idList = Lists.newArrayList();
        }
        return idList;
    }

    public void  setIdList(List<CouponManageIdData> value) {
        this.idList = value;
    }

    public DeleteData withIdList(List<CouponManageIdData> value) {
        setIdList(value);
        return this;
    }

    public DeleteData withIdList(List<CouponManageIdData> value, List<CouponManageIdData> defaultValue) {
        setIdList(value == null ? defaultValue : value);
        return this;
    }

    public DeleteData addIdList(CouponManageIdData value) {
        if(idList == null) {
            idList = Lists.newArrayList();
        }
        this.idList.add(value);
        return this;
    }

    public Object getValueOf(String name) {
        switch(name) {
        case "idList": return getIdList();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if(!(o instanceof DeleteData)) return false;
        return signature().equals(((DeleteData)o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean DeleteData has no signature defined, no hash code or equals possible.");
    }
}
